/*
 * Copyright (C) Michael Opitz
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA
 */
#ifndef MUSIC_ACCEPTOR_H
#define MUSIC_ACCEPTOR_H

#include "../handler/event_handler.h"
#include "../handler/multicaster.h"
#include "../network/configurator.h"
#include "../network/connection_manager.h"
#include "../network/network.h"
#include "music_handler.h"

#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>

/** 
 * \brief This namespace includes all user-specific handlers for the iRoom.
 * \author Michael Opitz
 */
namespace user_handler {
	/** 
	 * \brief This class handles new connection from the connection_listener
	 * which listens on the music-port.
	 */
	class music_acceptor : public handler::event_handler {
	public:
		/** 
		 * \brief music_acceptor creates the acceptor
		 * 
		 * \param mgr is a pointer to the connection-manager
		 * \param multi is a pointer to the multicaster
		 * \param music is a pointer to the music-system
		 */
		music_acceptor(
			 boost::shared_ptr<network::connection_manager> mgr,
			 boost::weak_ptr<handler::multicaster> multi,
			 boost::shared_ptr<music::music_system> music)
		:_mgr(mgr), _multi(multi), _music(music) {}
		virtual ~music_acceptor() {}
		/** 
		 * \brief handle_event handles received events.
		 * 
		 * \param n is the received message.
		 */
		virtual void handle_event(
			boost::shared_ptr<network::message> n);
	private:
		boost::weak_ptr<handler::multicaster> _multi;
		boost::shared_ptr<music::music_system> _music;
		boost::shared_ptr<network::connection_manager> _mgr;
	};
}

#endif

